<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/DonHang.php';
$donhangOb = new DonHang();
$donhang = $donhangOb->layChiTietDonHang($_GET['id']);
?>
<h2 align="center">THÔNG TIN CHI TIẾT</H3>
<table style="width: 100%">
    <thead>
        <tr>
            <th scope="col" align="left">STT</th>
            <th scope="col" align="left">ID_Sản phẩm</th>
            <th scope="col" align="left">Sản phẩm</th>
            <th scope="col" align="left">Số lượng</th>
            <th scope="col" align="left">Đơn giá</th>
            <th scope="col" align="left">Thành tiền</th>
        </tr>
    </thead>
    <?php
    $i = 0;
    $thanhtien = 0;
    $tongcong = 0;
    ?>
    <?php while ($dh = mysql_fetch_assoc($donhang)): ?>
        <?php $SP = $donhangOb->layTenSanPham($dh['sanpham_id']) ?>
        <?php $tongcong += $thanhtien ?>
        <tbody>
            <tr>
                <td scope="col"><?php echo++$i; ?></td>
                <td scope="col"><?php echo $dh['sanpham_id']; ?></td>
                <td scope="col"><?php echo $SP['ten'] ?></td>
                <td scope="col"><?php echo $dh['soluong']; ?></td>
                <td scope="col"><?php echo number_format($dh['dongiahientai']); ?></td>
                <td scope="col"><?php echo number_format($thanhtien = $dh['soluong'] * $dh['dongiahientai']); ?></td>
            </tr>
        </tbody>

    <?php endwhile; ?>
    <tfoot>
        <tr>
            <td colspan="5" scope="col">Tông tiền cần phải thanh toán</td>
            <td colspan="1" scope="col"><?php echo number_format($tongcong) ?></td>
        </tr>
    </tfoot>